﻿//
// *************************************************************************************
// WP-Framework
//
// Developed by 
// Lukas Kretschmar (lkretschmar.dev@bluewin.ch)
//
// Switzerland, Copyright (c) 2013 lkretschmar
// This content is released under the MIT License (http://opensource.org/licenses/MIT).
//     
// *************************************************************************************
//
//
			

using System;
using System.Linq.Expressions;
using KretschIT.WP_Fx.Core.Validation;

namespace KretschIT.WP_Fx.EasyMoq.Matchers
{
    internal abstract class ConditionalMatcher : BaseMatcher<MethodCallExpression>
    {
        private static readonly Func<object, bool> defaultCondition = (o => true);

        public ConditionalMatcher(MethodCallExpression expression) 
            : base(expression)
        {
            
        }

        protected override void Validate(MethodCallExpression expression)
        {
            It.IsValid(() => expression, c => c.Method.DeclaringType == typeof(Allow));
        }

        protected abstract Func<object, bool> Condition { get; }

        protected override bool CompareValue(object value)
        {
            return this.Condition(value);
        }
    }
}
